\section{Control System Design}\label{sec:control-method}
The controller design consists of two main concepts which are brought together. Namely, gain scheduling and LQR. These methods make up the bulk of controller design, but we have introduced modifications in order to improve the resulting robotic walking. This section, therefore, describes LQR and gain scheduling and how they were modified to fit the problem of interest and discusses the interplay between them.

\subsection{Controller Design Methods}
Due to the hybrid nature of the problem and the complex nonlinear dynamics, it is not straightforward to design linear controllers to track trajectories. In order to do this properly, one must first design linearized models of the system at various points along a prescribed trajectory. Then {\em gain scheduling} can be used with a {\em scheduling index} or {\em scheduling variable}. In order to motivate the choice of trajectory, it will be illuminating to briefly introduce Human-Inspired Control \cite{SPSA11}.

\subsubsection{Gain Scheduling}
Assume we have a prescribed trajectory $\xi : \Z_{1}^{K} \to \R^{n}$, the appropriate linearized model can be expressed in terms of the $\xi$ coordinates. For a given value of scheduling index $k$, one can define coordinates
\begin{align}
    \label{eq:linear-coords}
    \delta \xi_{k}(t) = x(t) - \xi_{k}(t).
\end{align}
and a linearized dynamic model
\begin{align}
    \label{eq:linear-model}
    \delta \dot{x}_{k}(t) &= A_{k} \delta x_{k}(t) + B_{k} u(t),\\
    \delta y(t) &= C_{k} \delta x(t) + D_{k} u(t).
\end{align}
where
\begin{align}
    \label{eq:linear-model-matrices}
    A_{k} = \pd{f}{x}(\xi_k), \quad B_{k} = g(\xi_k), \quad C_{k} = \pd{y}{x},
\end{align}
where $y$ represents human outputs.

As we are dealing with a rather complex problem, we have opted for a discrete scheduling index, denoted by $k$, in place of a continuous scheduling variable. One can determine the appropriate index for any given point in time in a variety of manners. A map can be formulated which relates time or state to the index. Mathematically, the index is written as

\subsubsection{Linear Quadratic Regulator}
The linear quadratic regulator (LQR) method with gain scheduling was selected for controller design.
For the state space system
\begin{align*}
    \dot{x}(t) &= Ax(t) + Bu(t),\\
    y(t) &= Cx(t) + Du(t),
\end{align*}
the optimal state feedback gain is sought which minimizes the cost functional
\begin{align*}
    J &= \frac{1}{2} \int_{0}^{\infty} \! (x^{T}(t) Q x(t) + u^{T}(t) R u(t)) \ dt,
\end{align*}
with $Q$ a symmetric, positive definite state weighting matrix and $R$ a symmetric, positive definite control weighting matrix. The control gain which minimizes this functional is given by
\begin{align*}
    u(t) &= -G x (t),\\
    G &= R^{-1} B^{T} K,
\end{align*}
where K is the solution of the algebraic Riccati equation:
\begin{align*}
    -K A - A^{T} K - Q + K B R^{-1} B^{T} K &= 0.
\end{align*}
For trajectory tracking, the linear model dynamics is represented in terms of a scheduling variable, $\tau$.
\begin{align*}
    \delta \dot{x}_{k}(t) &= A_{k} \delta x_{k}(t) + B_{k} u(t),\\
    \delta y(t) &= C_{k} \delta x(t) + D_{k} u(t).
\end{align*}
The LQR design process detailed above is then executed for each operating point along the trajectory with respect to the scheduling variable to obtain a series of gains. By an abuse of notation, the subscripts are dropped where not necessary. During operation, the system output updates the current operating point which in turn updates the compensator gain.
\begin{align*}
    \tau &= f(y(t)),\\
    u(t) &= -G(\tau) x(t).
\end{align*}
The resulting loop transfer function, denoted by $G_{LQ}(s)$, induced by the LQR design method will be:
\begin{align*}
	G_{LQ}(s,\tau) &= G(\tau)(sI-A)^{-1}B
\end{align*}
Now, assuming that $R = R^{T} > 0$ is diagonal, the following LQR robustness properties are guaranteed:
\begin{align*}
	\sigma_{\text{min}}(I+G_{LQ}(j\omega,\tau) &\ge 1,~~ \forall \omega, \\
	\sigma_{\text{min}}(I+G^{-1}_{LQ}(j\omega,\tau)) &\ge \frac{1}{2}, ~~ \forall \omega.
\end{align*}
In terms of the gain and phase margin, the following properties are satisfied:
\begin{itemize}
    \item upward gain margin is infinite;
\item downward gain margin is at least $\frac{1}{2}$; and
\item phase margin is at least $\pm 60\%$.
\end{itemize}

\subsection{Design Method Modifications}

In order to apply LQR to this project. It was necessary to implement gain scheduling. This naturally leads to the requirement for a scheduling variable. The is not so difficult a task on a low dimensional system, however, the biped studied in this project is a ten-dimensional manifold. Gain scheduling for all ten variables would require massive computation. However, analysis of human walking indicates that the hip moves forward monotonically (and approximately linearly) with time \cite{acc_2012_sa_01}. Thus, we chose to use hip position instead of the system states to parameterize gain. Thus, we have used {\em model reduction} to reduce the gain scheduling index to a one-dimensional representation.